#include "..\..\StdAfx.h"
#include "VisitBankAndDepositGold.h"
#include "GoHomeAndSleepTilRested.h"
#include "EnterMineAndDigForNugget.h"

VisitBankAndDepositGold::~VisitBankAndDepositGold(void)
{
}

bool VisitBankAndDepositGold::Enter(Miner* pEntity, float fTime)
{
	_TRACE(_T("Enter VisitBankAndDepositGold.\n"));
	if (pEntity->Location() != Bank)
		pEntity->SetDestination(Bank);

	m_fStateEnterTime = fTime;
	return true;
}

bool VisitBankAndDepositGold::Execute(Miner* pEntity, float fTime)
{
	if (pEntity->Location() != Bank)
		return pEntity->Walking(fTime);

	pEntity->DepositGold();

	if (pEntity->Reached())
		return pEntity->GetFSM()->ChangeState(GoHomeAndSleepTilRested::Instance(), fTime);
	else
		return pEntity->GetFSM()->ChangeState(EnterMineAndDigForNugget::Instance(), fTime);
}

bool VisitBankAndDepositGold::Exit(Miner* pEntity, float fTime)
{
	return true;
}